<%@ page import="java.util.*" %>
<%@ page import="com.db.tracker.vo.*" %>
<%@ page import="java.sql.CallableStatement" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.SQLException" %>
<%@ page import="java.text.*" %>
<%@ page import="java.io.*" %>
<%@ page import="com.db.gef.db.DBConnection" %>
<%@ page import="com.db.gef.db.DBConnectionManager" %>
<%@ page import="com.db.tracker.util.*" %>
<%@ page import="com.db.tracker.*" %>
<%@ page import="java.io.File" %>

<% 


try {
		 session = request.getSession();
			System.out.println("user_id" +session.getAttribute("USER_ID"));
			if (session.getAttribute("USER_ID") == null
					|| !((String) session.getAttribute("SESSION_ID"))
							.equals(session.getId())) {
				try {
					response.sendRedirect("LoginPage.jsp");
				} catch (IOException ioe) {
					ioe.printStackTrace();
				}
	
			} else {


//System.out.println("exx id..." + (String)request.getParameter("SESSION_ID"));
//if ("exit".equals((String)request.getParameter("SESSION_ID"))) {response.sendRedirect("LoginPage.jsp"); }






%>
<script>


function sendScript(Jobedit,serverN)
{
    //email();


	if(validate()) {
	
	document.mainPage.Job.value=trim(document.mainPage.Job.value);
	if(  Jobedit != document.mainPage.Job.value)
		{alert("You can not edit Script Name");}
	else if(serverN !=document.mainPage.RunsFrom.value){alert("You can not edit Runs From");}
	else{
			document.mainPage.edited.value='yes';
			document.mainPage.savesend.value='yes';	
			document.mainPage.submit();
			
		}
	}
	
	

}
function openNothing(){

document.mainPage.datacenterflag.value="yes";



}


function addsendScript()
{	if(validate()) {
		document.mainPage.added.value='yes';
		document.mainPage.savesend.value='yes';	
		document.mainPage.submit();
	}

}

function uploadpage()
{
	//alert("hiii" + document.mainPage.Job.value);
document.mainPage.Job.value=trim(document.mainPage.Job.value);
if(document.mainPage.Job.value == "" ) {alert("Job cannot be empty");}
else {
dwin = window.open("uploadpage.jsp?folder="+document.mainPage.Job.value,"_blank","width=600,height=400,scrollbars=yes,resizable=yes");
}
}

function loopSelected()
{
	var selectedArray = "";
	var temp = "";
    var selObj = document.getElementById('dayoption');
    var i;
    
	//alert(selObj.options.length);
	 for (i=0; i<selObj.options.length; i++) {
		
		if (selObj.options[i].selected) {
		selectedArray =  selectedArray + ',' + selObj.options[i].value  ;
     
		}
	}
	 //alert("select" + selectedArray);
	document.mainPage.days.value = selectedArray;
	temp = selectedArray;
	//alert("temp" + temp);
	//alert("selectffff" + document.mainPage.days.value + selectedArray);
}


function aScript()
{
	if(validate()) {
		document.mainPage.added.value='yes';
		document.mainPage.submit();
	}
}
function trim(sString) {
   sTrimmedString = "";
   if (sString != "") {
      var iStart = 0;
      var iEnd = sString.length - 1;
     // var sWhitespace = " \t\f\n\r\v";
	 var sWhitespace = "   ";


      while (sWhitespace.indexOf(sString.charAt(iStart)) != -1) {
         iStart++;
         if (iStart > iEnd)
            break;
      }

      // If the string not just whitespace
      if (iStart <= iEnd) {
         while (sWhitespace.indexOf(sString.charAt(iEnd)) != -1)
            iEnd--;
         sTrimmedString = sString.substring(iStart,++iEnd);
      }
   }
   return sTrimmedString;
}


function eScript(Jobedit,serverN)
{	
	
	if(validate()) {
	//email();
	//alert(Jobedit);
	//removeSpace(document.mainPage.RunsTo);
	document.mainPage.Job.value=trim(document.mainPage.Job.value);
	if(  Jobedit != document.mainPage.Job.value)
		{alert("You can not edit Script Name");}
	else if(serverN !=document.mainPage.RunsFrom.value){alert("You can not edit Server Name");}
	else{

			document.mainPage.edited.value='yes';
			document.mainPage.submit();
		}
	}
}
function addN()
{
	dwin = window.open("addEditScript.jsp","_self","width=840,height=665,scrollbars=yes,resizable=yes");
}




function backtomain()
{
	//dwin = window.open("mainpage.jsp","_self","width=840,height=665,scrollbars=yes,resizable=yes");
	document.mainPage.action="mainpage.jsp";
	document.mainPage.submit();


}
function notAvail(field)
{
		
		if(field == "FromSource")
	{
		if("Data Not Available" == document.mainPage.FromSource.value){
			//alert("hiii");
			document.mainPage.FromSource.value="";
		document.mainPage.FromSource.style.backgroundColor="";
		}
	}

		if(field == "RunsTo")
	{
		if("Data Not Available" == document.mainPage.RunsTo.value){
		document.mainPage.RunsTo.value="";
		document.mainPage.RunsTo.style.backgroundColor="";
		}
	}

		if(field == "InternalFilename")
	{	if("Data Not Available" == document.mainPage.InternalFilename.value){
		document.mainPage.InternalFilename.value="";
		document.mainPage.InternalFilename.style.backgroundColor="";
		}
	}

		if(field == "ExternalFilename")
	{
		if("Data Not Available" == document.mainPage.ExternalFilename.value){
		document.mainPage.ExternalFilename.value="";
		document.mainPage.ExternalFilename.style.backgroundColor="";
		}
	}

		if(field == "RemoteContact")
	{	
		if("Data Not Available" == document.mainPage.RemoteContact.value){
		document.mainPage.RemoteContact.value="";
		document.mainPage.RemoteContact.style.backgroundColor="";
		}
	}


		if(field == "DestBizArea")
	{	
		if("Data Not Available" == document.mainPage.DestBizArea.value){
		document.mainPage.DestBizArea.value="";
		document.mainPage.DestBizArea.style.backgroundColor="";
		}
	}
		if(field == "DestBizContact")
	{	
		if("Data Not Available" == document.mainPage.DestBizContact.value){
		document.mainPage.DestBizContact.value="";
		document.mainPage.DestBizContact.style.backgroundColor="";
		}
	}
		if(field == "ExecsAnotherScript")
	{
		if("Data Not Available" == document.mainPage.ExecsAnotherScript.value){
		document.mainPage.ExecsAnotherScript.value="";
		document.mainPage.ExecsAnotherScript.style.backgroundColor="";
		}
	}



		if(field == "MemName_CM")
	{	
		if("Data Not Available" == document.mainPage.MemName_CM.value){
		document.mainPage.MemName_CM.value="";
		document.mainPage.MemName_CM.style.backgroundColor="";
		}
	}

	if(field == "DataCentre_CM")
	{	
		if("Data Not Available" == document.mainPage.DataCentre_CM.value){
		document.mainPage.DataCentre_CM.value="";
		document.mainPage.DataCentre_CM.style.backgroundColor="";
		}
	}

	if(field == "Group_CM")
	{	
		if("Data Not Available" == document.mainPage.Group_CM.value){
		document.mainPage.Group_CM.value="";
		document.mainPage.Group_CM.style.backgroundColor="";
		}
	}

	if(field == "NodeID_CM")
	{	
		if("Data Not Available" == document.mainPage.NodeID_CM.value){
		document.mainPage.NodeID_CM.value="";
		document.mainPage.NodeID_CM.style.backgroundColor="";
		}
	}



		if(field == "RunTime_CM")
	{	
		if("Data Not Available" == document.mainPage.RunTime_CM.value){
		document.mainPage.RunTime_CM.value="";
		document.mainPage.RunTime_CM.style.backgroundColor="";
		}
	}
		if(field == "Misc_CM")
	{
		if("Data Not Available" == document.mainPage.Misc_CM.value){
		document.mainPage.Misc_CM.value="";
		document.mainPage.Misc_CM.style.backgroundColor="";
		}
	}

	
		if(field == "CommandLine_CM")
	{
		if("Data Not Available" == document.mainPage.CommandLine_CM.value){
		document.mainPage.CommandLine_CM.value="";
		document.mainPage.CommandLine_CM.style.backgroundColor="";
		}
	}
 

 	if(field == "DepInNames_CM")
	{
		if("Data Not Available" == document.mainPage.DepInNames_CM.value){
		document.mainPage.DepInNames_CM.value="";
		document.mainPage.DepInNames_CM.style.backgroundColor="";
		}
	}

		if(field == "DepOutNames_CM")
	{
		if("Data Not Available" == document.mainPage.DepOutNames_CM.value){
		document.mainPage.DepOutNames_CM.value="";
		document.mainPage.DepOutNames_CM.style.backgroundColor="";
		}
	}


 
 



}

function email()
{		
	
	var Job=document.mainPage.Job.value;
	var RunsFrom=document.mainPage.RunsFrom.value;
	var FeedDirection=document.mainPage.FeedDirection.value;
	var FromSource=document.mainPage.FromSource.value;
	var RunsTo=document.mainPage.RunsTo.value;
	var InternalFilename=document.mainPage.InternalFilename.value;
	var  ExternalFilename=document.mainPage.ExternalFilename.value;
	var Summary=document.mainPage.Summary.value;
	var LocalContact=document.mainPage.LocalContact.value;
	var  RemoteContact=document.mainPage.RemoteContact.value;
	var DestBizArea=document.mainPage.DestBizArea.value;
	var DestBizContact=document.mainPage.DestBizContact.value;
	var ExecutedBy=document.mainPage.ExecutedBy.value;
	var ExecsAnotherScript=document.mainPage.ExecsAnotherScript.value;
	var DataCentre_CM=document.mainPage.DataCentre_CM.value;
	var Application_CM=document.mainPage.Application_CM.value;
	var Group_CM=document.mainPage.Group_CM.value;
	var MemName_CM=document.mainPage.MemName_CM.value;
	var NodeID_CM=document.mainPage.NodeID_CM.value;
	var Owner_CM=document.mainPage.Owner_CM.value;
	var CommandLine_CM=document.mainPage.CommandLine_CM.value;
	var Days_CM=document.mainPage.Days_CM.value;
	var DependenciesIN_CM=document.mainPage.DependenciesIN_CM.value;
	var DependenciesOUT_CM=document.mainPage.DependenciesOUT_CM.value;
	var RunTime_CM=document.mainPage.RunTime_CM.value;
	var Misc_CM=document.mainPage.Misc_CM.value;

	alert(" Hi \n" +
		"Job : " + Job + "\n RunsFrom : " +  RunsFrom + " \nFeedDirection : " + FeedDirection + " \nFromSource  : " + FromSource +
		"\n RunsTo : " +RunsTo + " \n InternalFilename : " +InternalFilename + "\nExternalFilename  : " + ExternalFilename +
		"\nSummary : " + Summary + "\nLocalContact  : "  + LocalContact + "\nRemoteContact : " + RemoteContact);


}

function cancelScript()
{
	document.mainPage.action="mainpage.jsp";
	document.mainPage.submit();
}

function SeaResult()
{
	//document.mainPage.action="SearchPage.jsp";
	dwin = window.open("SearchPage.jsp","_self","width=840,height=665,scrollbars=yes,resizable=yes");
	//document.mainPage.submit();
}

function validate() {
	var validate = true;
	//alert("Please");
				var fs;
				var len;
	loopSelected();
	document.mainPage.Job.value=trim(document.mainPage.Job.value);
	document.mainPage.FromSource.value=trim(document.mainPage.FromSource.value);
	document.mainPage.RunsTo.value=trim(document.mainPage.RunsTo.value);
	document.mainPage.InternalFilename.value=trim(document.mainPage.InternalFilename.value);
	document.mainPage.ExternalFilename.value=trim(document.mainPage.ExternalFilename.value);
	document.mainPage.Summary.value=trim(document.mainPage.Summary.value);
	document.mainPage.LocalContact.value=trim(document.mainPage.LocalContact.value);
	document.mainPage.RemoteContact.value=trim(document.mainPage.RemoteContact.value);
	document.mainPage.DestBizArea.value=trim(document.mainPage.DestBizArea.value);
	document.mainPage.DestBizContact.value=trim(document.mainPage.DestBizContact.value);
	document.mainPage.ExecsAnotherScript.value=trim(document.mainPage.ExecsAnotherScript.value);
	document.mainPage.MemName_CM.value=trim(document.mainPage.MemName_CM.value);
	document.mainPage.CommandLine_CM.value=trim(document.mainPage.CommandLine_CM.value);
	document.mainPage.RunTime_CM.value=trim(document.mainPage.RunTime_CM.value);
	document.mainPage.Misc_CM.value=trim(document.mainPage.Misc_CM.value);
	document.mainPage.DepInNames_CM.value=trim(document.mainPage.DepInNames_CM.value);
	document.mainPage.DepOutNames_CM.value=trim(document.mainPage.DepOutNames_CM.value);
	document.mainPage.Username.value=trim(document.mainPage.Username.value);
	document.mainPage.Application_CM.value=trim(document.mainPage.Application_CM.value);
	document.mainPage.Owner_CM.value=trim(document.mainPage.Owner_CM.value);

	document.mainPage.RunsFrom.value=trim(document.mainPage.RunsFrom.value);
	document.mainPage.DataCentre_CM.value=trim(document.mainPage.DataCentre_CM.value);
	document.mainPage.Group_CM.value=trim(document.mainPage.Group_CM.value);
	document.mainPage.NodeID_CM.value=trim(document.mainPage.NodeID_CM.value);

	

		
		//alert("length ", len);
		if(document.mainPage.Summary.value.length > 255) { validate = false;alert("Summary can not exceed 255 characters");
			document.mainPage.Summary.focus();
			document.mainPage.Summary.select();
			return validate;
		}
		
		else if(document.mainPage.Job.value.length > 100) { validate = false;alert("Job can not exceed  100 characters");
			document.mainPage.Job.focus();
			document.mainPage.Job.select();
			return validate;
		}
		else if(document.mainPage.RunsFrom.value.length > 60) { validate = false;alert("RunsFrom can not exceed  60 characters");
			document.mainPage.RunsFrom.focus();
			document.mainPage.RunsFrom.select();
			return validate;
		}


		else if(document.mainPage.FromSource.value.length > 100) { validate = false;alert("From Source can not exceed  100 characters");
			document.mainPage.FromSource.focus();
			document.mainPage.FromSource.select();
			return validate;
		}
		
		else if(document.mainPage.RunsTo.value.length > 100) { validate = false;alert("Runs To can not exceed  100 characters");
			document.mainPage.RunsTo.focus();
			document.mainPage.RunsTo.select();
			return validate;
		}
	
	else if(document.mainPage.InternalFilename.value.length > 100) { validate = false;alert("Internal Filename can not exceed  100 characters");
		document.mainPage.InternalFilename.focus();
		document.mainPage.InternalFilename.select();
		return validate;
	}

	else if(document.mainPage.ExternalFilename.value.length > 100) { validate = false;alert("External Filename can not exceed  100 characters");
		document.mainPage.ExternalFilename.focus();
		document.mainPage.ExternalFilename.select();
		return validate;
	}

	else if(document.mainPage.LocalContact.value.length > 100) { validate = false;alert("Local Contact can not exceed  100 characters");
		document.mainPage.LocalContact.focus();
		document.mainPage.LocalContact.select();
		return validate;
	}

	else if(document.mainPage.RemoteContact.value.length > 100) { validate = false;alert("Remote Contact can not exceed  100 characters");
		document.mainPage.RemoteContact.focus();
		document.mainPage.RemoteContact.select();
		return validate;
	}

	else if(document.mainPage.DestBizArea.value.length > 100) { validate = false;alert("Destination Biz Area can not exceed  60 characters");
		document.mainPage.DestBizArea.focus();
		document.mainPage.DestBizArea.select();
		return validate;
	}

	else if(document.mainPage.DestBizContact.value.length > 100) { validate = false;alert("Destination Biz Contact can not exceed  60 characters");
		document.mainPage.DestBizContact.focus();
		document.mainPage.DestBizContact.select();
		return validate;
	}

	else if(document.mainPage.ExecutedBy.value.length > 100) { validate = false;alert("Executed By can not exceed more than 100 characters");
		document.mainPage.ExecutedBy.focus();
		document.mainPage.ExecutedBy.select();
		return validate;
	}

	else if(document.mainPage.ExecsAnotherScript.value.length > 100) { validate = false;
		alert("Executes Another Script can not exceed  100 characters");
		document.mainPage.ExecsAnotherScript.focus();
		document.mainPage.ExecsAnotherScript.select();
		return validate;
	}
	else if(document.mainPage.DataCentre_CM.value.length > 25) { validate = false;
		alert("Data Centre can not exceed 25 characters");
		document.mainPage.DataCentre_CM.focus();
		document.mainPage.DataCentre_CM.select();
		return validate;
	}
	else if(document.mainPage.Group_CM.value.length > 25) { validate = false;
		alert("Group can not exceed 25 characters");
		document.mainPage.Group_CM.focus();
		document.mainPage.Group_CM.select();
		return validate;
	}
	else if(document.mainPage.NodeID_CM.value.length > 30) { validate = false;
		alert("NodeID can not exceed 100 characters");
		document.mainPage.NodeID_CM.focus();
		document.mainPage.NodeID_CM.select();
		return validate;
	}











	else if(document.mainPage.MemName_CM.value.length > 100) { validate = false;
		alert("Mem Name can not exceed 100 characters");
		document.mainPage.MemName_CM.focus();
		document.mainPage.MemName_CM.select();
		return validate;
	}

	else if(document.mainPage.Owner_CM.value.length > 50) { validate = false;alert("Owner can not exceed  50 characters");
		document.mainPage.Owner_CM.focus();
		document.mainPage.Owner_CM.select();
		return validate;
	}

	else if(document.mainPage.CommandLine_CM.value.length > 100) { validate = false;alert("Command Line can not exceed  100 characters");
		document.mainPage.CommandLine_CM.focus();
		document.mainPage.CommandLine_CM.select();
		return validate;
	}

	else if(document.mainPage.Application_CM.value.length > 25) { validate = false;alert("Application can not exceed  25 characters");
	document.mainPage.Application_CM.focus();
	document.mainPage.Application_CM.select();
	return validate;
	}


	else if(document.mainPage.RunTime_CM.value.length > 100) { validate = false;alert("Run Time can not exceed 50 characters");
		document.mainPage.RunTime_CM.focus();
		document.mainPage.RunTime_CM.select();
		return validate;
	}

	else if(document.mainPage.Misc_CM.value.length > 100) { validate = false;
		alert("Miscellaneous  can not exceed 100 characters");
		document.mainPage.Misc_CM.focus();
		document.mainPage.Misc_CM.select();
		return validate;
	}

	else if(document.mainPage.DepInNames_CM.value.length > 100) { validate = false;alert("DependencyIn Names  can not exceed  200 characters");
		document.mainPage.DepInNames_CM.focus();
		document.mainPage.DepInNames_CM.select();
		return validate;
	}
	

	else if(document.mainPage.DepOutNames_CM.value.length > 100) { validate = false;alert("DependencyOut Names  can not exceed  200 characters");
		document.mainPage.DepOutNames_CM.focus();
		document.mainPage.DepOutNames_CM.select();
		return validate;
	}
	
	else if(document.mainPage.Username.value.length > 100) { validate = false;alert("Username  can not exceed  50 characters");
		
		document.mainPage.Username.focus();
		document.mainPage.Username.select();
		return validate;
	}
	
	
	

	if(document.mainPage.Job.value == "") {
		alert("Please enter Job Name");
		validate = false;
		document.mainPage.Job.focus();
		document.mainPage.Job.select();
		return validate;
	}
	else if(document.mainPage.RunsFrom.value == ""){
		alert("Please enter Server Name");
		validate = false;

		document.mainPage.RunsFrom.focus();
		document.mainPage.RunsFrom.select();
		return validate;
	}

	
	else if(document.mainPage.Summary.value == ""){
		alert("Please enter Summary");
		validate = false;
		document.mainPage.Summary.focus();
		document.mainPage.Summary.select();
		
		return validate;

	}
	
	else if(document.mainPage.LocalContact.value == ""){
		alert("Please enter LocalContact");
		validate = false;
		document.mainPage.LocalContact.focus();
		document.mainPage.LocalContact.select();
		return validate;

	}

	else if(document.mainPage.Application_CM.value == ""){
		alert("Please enter Application");
		validate = false;
		document.mainPage.Application_CM.focus();
		document.mainPage.Application_CM.select();
		return validate;

	}

	else if(document.mainPage.Owner_CM.value == ""){
		alert("Please enter Owner");
		validate = false;
		document.mainPage.Owner_CM.focus();
		document.mainPage.Owner_CM.select();
		return validate;

	}
	if( (document.mainPage.DependenciesIN_CM.value =="Yes" || document.mainPage.DependenciesIN_CM.value == "Several" ) && (document.mainPage.DepInNames_CM.value == ""))
	{
		alert("Please enter Dependency In Names");
		document.mainPage.DepInNames_CM.focus();
		document.mainPage.DepInNames_CM.select();
		validate=false;
		return validate;
	}

	if( (document.mainPage.DependenciesOUT_CM.value =="Yes" || document.mainPage.DependenciesOUT_CM.value == "Several" ) && (document.mainPage.DepOutNames_CM.value == ""))
	{
		alert("Please enter Dependency Out Names");
		document.mainPage.DepOutNames_CM.focus();
		document.mainPage.DepOutNames_CM.select();
		validate=false;
		return validate;
	}



	 if(document.mainPage.RunTime_CM.value == "" && document.mainPage.DepInNames_CM.value == ""){
		alert("Please enter RunTime");
		validate = false;
		document.mainPage.RunTime_CM.focus();
		document.mainPage.RunTime_CM.select();
		return validate;

	}



	else if(document.mainPage.Username.value == ""){
		alert("Please enter Username");
		validate = false;
		document.mainPage.Username.focus();
		document.mainPage.Username.select();
		return validate;

	}


	/*else if(document.mainPage.CommandLine_CM.value == ""){
		alert("Please enter Command Line");
		validate = false;
		document.mainPage.CommandLine_CM.focus();
		document.mainPage.CommandLine_CM.select();
		return validate;

	}*/



	 
	 if(document.mainPage.FromSource.value == ""){
		//alert("Please enter From Source");
		//validate = false;

		document.mainPage.FromSource.value="Data Not Available";
		//document.mainPage.colorFromSource.value='yes';
		//document.mainPage.FromSource.fgColor='#ccoccc'
		//document.mainPage.FromSource.select();
		//ocument.mainPage.InternalFilename.select();
		//document.mainPage.ExternalFilename.select();
		//alert("colorff");
	}
	else{
		valSpace(document.mainPage.FromSource);
	}
	
	 if(document.mainPage.RunsTo.value == ""){
		document.mainPage.RunsTo.value="Data Not Available";
		//alert("Please enter Runs To");
		//validate = false;

		
	}

	else{
		valSpace(document.mainPage.RunsTo);
	}

	if(document.mainPage.CommandLine_CM.value == ""){
		document.mainPage.CommandLine_CM.value="Data Not Available";
	}
	else{
		valSpace(document.mainPage.CommandLine_CM);
	}


	 if(document.mainPage.InternalFilename.value == ""){
		//alert("Please enter Internal Filename");
		//validate = false;
		document.mainPage.InternalFilename.value="Data Not Available";
		
	}
	else{
		valSpace(document.mainPage.InternalFilename);
	}
	


	 if(document.mainPage.ExternalFilename.value == ""){
		//alert("Please enter External Filename");
		//validate = false;
		document.mainPage.ExternalFilename.value="Data Not Available";
		
	}

	else{
		valSpace(document.mainPage.ExternalFilename);
	}
	
	 if(document.mainPage.RemoteContact.value == ""){
		
		document.mainPage.RemoteContact.value="Data Not Available";
		
	}

	else{
		valSpace(document.mainPage.RemoteContact);
	}
	


	 if(document.mainPage.DestBizArea.value == ""){
		
		document.mainPage.DestBizArea.value="Data Not Available";
		
	}


	else{
		valSpace(document.mainPage.DestBizArea);
	}
	
	 if(document.mainPage.DestBizContact.value == ""){
		
		document.mainPage.DestBizContact.value="Data Not Available";
		
	}
	else{
		valSpace(document.mainPage.DestBizContact);
	}
	
	if(document.mainPage.ExecsAnotherScript.value == ""){
		
		document.mainPage.ExecsAnotherScript.value="Data Not Available";
		}
	else{
		valSpace(document.mainPage.ExecsAnotherScript);
	}
	
	if(document.mainPage.DataCentre_CM.value == ""){
		
		document.mainPage.DataCentre_CM.value="Data Not Available";
		
	}
		else{
		valSpace(document.mainPage.DataCentre_CM);
	}

	if(document.mainPage.Group_CM.value == ""){
		
		document.mainPage.Group_CM.value="Data Not Available";
		
	}
		else{
		valSpace(document.mainPage.Group_CM);
	}

	if(document.mainPage.NodeID_CM.value == ""){
		
		document.mainPage.NodeID_CM.value="Data Not Available";
		
	}
		else{
		valSpace(document.mainPage.NodeID_CM);
	}








	if(document.mainPage.MemName_CM.value == ""){
		
		document.mainPage.MemName_CM.value="Data Not Available";
		
	}
		else{
		valSpace(document.mainPage.MemName_CM);
	}
	
	if(document.mainPage.RunTime_CM.value == ""){
		
		document.mainPage.RunTime_CM.value="Data Not Available";
	//alert("runt" + document.mainPage.RunTime_CM.value);
		
	}
	else{
		valSpace(document.mainPage.RunTime_CM);
	}

		if(document.mainPage.Misc_CM.value == ""){
		
		document.mainPage.Misc_CM.value="Data Not Available";
		
	}
	else{
		valSpace(document.mainPage.Misc_CM);
	}




	if(document.mainPage.DepInNames_CM.value == ""){
		
		document.mainPage.DepInNames_CM.value="Data Not Available";
		
	}
	else{
		valSpace(document.mainPage.DepInNames_CM);
	}



	if(document.mainPage.DepOutNames_CM.value == ""){
		
		document.mainPage.DepOutNames_CM.value="Data Not Available";
		
	}
	else{
		valSpace(document.mainPage.DepOutNames_CM);
	}



	return validate;
}
function valSpace(obj){
	var fs = obj.value;
		len = fs.length;
		for(i=0;len>0 && fs.indexOf(" ")==0;i++){
			fs = fs.substring(1,len-i);
		}
		if(len==i) obj.value="Data Not Available";
}

function download(path,filename)
{
	//alert(path+"   "+filename);
	dwin = window.open("openDocument.jsp?path="+path+ "&filename="+filename,"_blank","width=600,height=400,scrollbars=yes,resizable=yes");

}

</script>
<HTML>
<HEAD>
<link type="text/css" rel="stylesheet" href="styles/tracker_style.css">
<TITLE>Main Page</TITLE>
</HEAD>
<SCRIPT language="javascript" src="js/script.js" type="text/javascript"></SCRIPT>
<BODY>
<TABLE width ="750" border = "0">
	<TR>
		<TD colspan="2">
			<jsp:include page="HeaderNav.jsp" flush="true" />
		</TD>
	</TR>

</TABLE>

<FORM name="mainPage" action="addEditScript.jsp"  method="post" >
<input type="hidden" name="added" value="">
<input type="hidden" name="days" value="">
<input type="hidden" name="edited" value="">
<input type="hidden" name="colorFromSource" value="">
<input type="hidden" name="savesend" value="">
<input type="hidden" name="datacenterflag" value="">



<input type='hidden' name='Action' value=''>

<%  String editflag=null;
 String searchflag=null;
  String edited=null;
  String savesend=null;
	String added=null;
	String SValue=null;
	String jobN=null;
	String serverN=null;
	String Jobedit=null;
	String Value ;

	//String field="";
	String colorFromSource=null;
	ArrayList arraylist = null;
	ScriptVO scriptVO = null;
	ScriptVO scriptvoeditget  =null;
	//field=(String)request.getParameter("searchtag");
	//System.out.println("searchtag" + field);
	savesend = (String)request.getParameter("savesend");
	Jobedit = (String)request.getParameter("jobname");
	System.out.println("Jobedit" + Jobedit);	
	System.out.println("SaveSend" + savesend);	
	editflag = (String)request.getParameter("editflag");
	searchflag = (String)request.getParameter("searchflag");
	edited = (String)request.getParameter("edited");
	added = (String)request.getParameter("added");
	jobN=(String)request.getParameter("jobname");
	serverN=(String)request.getParameter("servername");
	System.out.println("editflag" + editflag);
	System.out.println("edited" + edited);
	System.out.println("jobN" + jobN);
	System.out.println("serverN" + serverN);
	System.out.println("added" + added);
	
	if (edited == null && added == null)
	{
	Properties property = new Properties();
    String filepath = new String();
	%> <table width=750>
	
	  <% try {
            //File propfile = new File(System.getProperty("tracker.properties.home")+"/"+"STtracker.properties");
            File propfile = new File(getServletContext().getInitParameter("tracker.properties.home")+"/"+"STtracker.properties");
			InputStream in = new FileInputStream(propfile);
            property.load(in);
            filepath = property.getProperty("DocumentPath");
            System.out.println("11111111111111111111111");
        }
        catch(Exception e) {
            System.out.println("LOADFILE>>>>>CONSTRUCTOR");
        }
	String path = filepath + Jobedit;
	 File totalpath=new  File(path) ;
	 	
	if (totalpath.isDirectory()) {
		File list[] = totalpath.listFiles();
		if(list.length >0 ){
		%>
		<tr><td align=left ><label class=link><b>Document</b>  </label></td></tr>
		<%  for(int i=0;i<list.length;i++){
			String filename =list[i].getName();
			
			%> 

	
		<tr><td align=left ><a href="javaScript:download('<%=path%>','<%=filename%>')" class=link> <%=filename%> </td></tr>




<%		}
		%>
		
		
<%	 }}


%>
<td align=right><input type="button"  class=whitebutton value="Upload Document" onclick="javascript:uploadpage()"></td>
</table>







<% } %>



<%	if( edited == null || editflag != null )
	{
			if (  editflag != null) {	// Edit Script			
				if ( jobN != null && serverN != null) {
					DBUtil dbutil = new DBUtil(getServletContext());				
					//arraylist = dbutil.getScriptDetails(jobN, serverN);
					  scriptVO = dbutil.getScriptDetails(jobN,serverN);
					//scriptVO = (ScriptVO) arraylist.get(0);
				}
			}
	     %>
		
		
			<TABLE width="750" border=0 name="tblReqs" cellpadding="0" cellspacing="1" style="BORDER:#000000 1px solid">


				
					<td class=smallfonthead colspan='4' bgcolor='#000077'>
						<B><%if ( editflag == null || "".equals(editflag)) {%>
							Add  New Script 
						<%}else{%>
							Edit Script
						<%}%>
						</B>
					</td>
				</tr>

				<tr height = 35 bgcolor=#EFEFEF >
					
					<td  class = bodyblue title="Script Name"> <LABEL><FONT size=-1><b>Job</b> <font color = "red">*</font></FONT></LABEL></td>
					
						<% Value = (scriptVO != null)?scriptVO.getJob():""; %>
						<td><INPUT type="text" name="Job"  size=30 class=bodyblue value="<%=Value%>">
					
					</td>
				
					<td class = bodyblue title="Server Name"><LABEL><FONT size=-1><b>Runs From</b> <font color = "red">*</font></FONT></LABEL></td>
					
						<%  Value = (scriptVO != null)?scriptVO.getRunsFrom():""; %>

					<td><input class=bodyblue name="RunsFrom" value='<%=Value%>'>
					<a href='javascript:openSelectWindow(document.mainPage.RunsFrom)'><img src='images/find.gif' border='0'></img></a>	
					</td>
		
				</tr>
				

					<tr height = 35 bgcolor=#EFEFEF >
					
					<td class = bodyblue><LABEL><FONT size=-1><b>Feed Direction </b></FONT></LABEL>
					
						<%  Value = (scriptVO != null)?scriptVO.getFeedDirection():""; System.out.println("Feedd"+ Value ); %></td>
					<td>	<select class=bodyblue name="FeedDirection"  >
						
						<option value=""> </option>
						<option value="In" <%=(editflag!=null && "In".equals(Value))?"selected":""%>>In</option>
						<option value="Out" <%=(editflag!=null && "Out".equals(Value))?"selected":""%>>Out</option>
						<option value="In&Out" <%=(editflag!=null && "In&Out".equals(Value))?"selected":""%>>In&Out</option>
						<option value="Local" <%=(editflag!=null && "Local".equals(Value))?"selected":""%>>Local</option>
						
						</select>
					</td>
				
				
				
				
					
					<td  class = bodyblue><LABEL><FONT size=-1><b>From Source</b> </FONT></LABEL></td>
					<td>
						<%  Value = (scriptVO != null)?scriptVO.getFromSource():""; 
				    if ("Data Not Available".equals(Value)) {%>
					
					<INPUT STYLE="  background-color:#72A4D2;"class="bodyblue" type="text" name="FromSource"  size=30  value="<%=Value.trim()%>" onfocus= "JavaScript:notAvail('FromSource')">
					<% } else { %> <INPUT class="bodyblue" type="text" name="FromSource"  size=30  value="<%=Value.trim()
					%>">
					<% } %>
					</td>
					
				</tr>		
				



				<tr height = 35 bgcolor=#EFEFEF>
					
					<td class = bodyblue><LABEL><FONT size=-1><b>Runs To <b></FONT></LABEL></td>
					<td >
						<%  Value = (scriptVO != null)?scriptVO.getRunsTo():""; 
					if ("Data Not Available".equals(Value)) {%>
					
					<INPUT STYLE="  background-color:#72A4D2;"class="bodyblue" type="text" name="RunsTo"  size=30  value="<%=Value%>" onfocus= "JavaScript:notAvail('RunsTo')" >
					<% } else { %> <INPUT class="bodyblue" type="text" name="RunsTo"  size=30  value="<%=Value%>">
					<% } %>
				
					</td>
				
				
					
					<td  class = bodyblue><LABEL><FONT size=-1><b>Internal File Name <b></FONT></LABEL></td>
					<td >
						<%  Value = (scriptVO != null)?scriptVO.getInternalFilename():""; 
					System.out.println("Internal fil" + Value);
					if ("Data Not Available".equals(Value)) {%>
					
					<INPUT STYLE="  background-color:#72A4D2;"class="bodyblue" type="text" name="InternalFilename"  size=30  value="<%=Value%>" onfocus= "JavaScript:notAvail('InternalFilename')" >
					<% } else { %> <INPUT class="bodyblue" type="text" name="InternalFilename"  size=30  value="<%=Value%>">
					<% } %>


					</td>
				</tr>			

				
				<tr height = 35 bgcolor=#EFEFEF>
					
					<td  class = bodyblue valign='top'><LABEL><FONT size=-1><b>External File Name</b> </FONT></LABEL></td>
					<td valign='top'>
						<%  Value = (scriptVO != null)?scriptVO.getExternalFilename():""; 
					if ("Data Not Available".equals(Value)) {%>
					<INPUT STYLE="  background-color:#72A4D2;"class="bodyblue" type="text" name="ExternalFilename"  size=30  		value="<%=Value%>" onfocus= "JavaScript:notAvail('ExternalFilename')" >
					<% } else { %> <INPUT class="bodyblue" type="text" name="ExternalFilename"  size=30  value="<%=Value%>">
					<% } %>
						
					</td>
				
				


				
					
					<td  title="Description"class = bodyblue valign='top'><LABEL><FONT size=-1><b>Summary</b> <font color = "red">*</font></FONT></LABEL></td>
					 <td>
						<%  Value = (scriptVO != null)?scriptVO.getSummary():""; %>
						<TEXTAREA  cols=35 rows=7 name="Summary" class="bodyblue" ><%=Value%></TEXTAREA>
					</td>
				</tr>	



				<tr height = 35  bgcolor=#EFEFEF>
					
					<td  title="Contact Person" class = bodyblue><LABEL><FONT size=-1><b>Local Contact</b> <font color = "red">*</font></FONT></LABEL></td>
					<td >
						<%  Value = (scriptVO != null)?scriptVO.getLocalContact():""; %>
						<INPUT type="text" name="LocalContact"  size=30 class=bodyblue value="<%=Value%>">
					</td>
				
					
					<td  title="Contact Person" class = bodyblue><LABEL><FONT size=-1><b>Remote Contact</b> </FONT></LABEL></td>
					<td >
						<%  Value = (scriptVO != null)?scriptVO.getRemoteContact():"";
						if ("Data Not Available".equals(Value)) {%>
					<INPUT STYLE="  background-color:#72A4D2;"class="bodyblue"  type="text" name="RemoteContact"  size=30  		value="<%=Value%>" onfocus= "JavaScript:notAvail('RemoteContact')" >
					<% } else { %> <INPUT class="bodyblue" type="text" name="RemoteContact"  size=30  value="<%=Value%>">
					<% } %>

						
					</td>
				</tr>	





					<tr height = 35 bgcolor=#EFEFEF>
					
					<td class = bodyblue><LABEL><FONT size=-1><b>Destination Biz Area</b> </FONT></LABEL></td>
					<td >
						<%  Value = (scriptVO != null)?scriptVO.getDestBizArea():""; 
						if ("Data Not Available".equals(Value)) {%>
					<INPUT STYLE="  background-color:#72A4D2;"class="bodyblue" type="text" name="DestBizArea"  size=30  		value="<%=Value%>" onfocus= "JavaScript:notAvail('DestBizArea')" >
					<% } else { %> <INPUT class="bodyblue" type="text" name="DestBizArea"  size=30  value="<%=Value%>">
					<% } %>
						
						
				
					<td  class = bodyblue><LABEL><FONT size=-1><b>Destination Biz Contact</b> </FONT></LABEL></td>
					<td >
						<%  Value = (scriptVO != null)?scriptVO.getDestBizContact():""; 

						if ("Data Not Available".equals(Value)) {%>
					<INPUT STYLE="  background-color:#72A4D2;"class="bodyblue" type="text" name="DestBizContact"  size=30  		value="<%=Value%>" onfocus= "JavaScript:notAvail('DestBizContact')" >
					<% } else { %> <INPUT class="bodyblue" type="text" name="DestBizContact"  size=30  value="<%=Value%>">
					<% } %>
						
					</td>
				</tr>	


				<tr height = 35 bgcolor=#EFEFEF>
					
					<td  class = bodyblue><LABEL><FONT size=-1><b>Executed By</b> </FONT></LABEL></td>
					<td >
						<%  Value = (scriptVO != null)?scriptVO.getExecutedBy():""; %>

						<select class=bodyblue name="ExecutedBy"  >
						
						<option value="ControlM" <%=(editflag!=null && "ControlM".equals(Value))?"selected":""%>>ControlM</option>

						
						</select>
						

					</td>
			
					<td  class = bodyblue><LABEL><FONT size=-1><b>Executes Another Script</b> </FONT></LABEL></td>
					<td >
						<%  Value = (scriptVO != null)?scriptVO.getExecsAnotherScript():""; 
			if ("Data Not Available".equals(Value)) {%>
					<INPUT STYLE="  background-color:#72A4D2;"class="bodyblue" type="text" name="ExecsAnotherScript"  size=30  		value="<%=Value%>" onfocus= "JavaScript:notAvail('ExecsAnotherScript')">
					<% } else { %> <INPUT class="bodyblue" type="text" name="ExecsAnotherScript"  size=30  value="<%=Value%>">
					<% } %>
						
						
					</td>
				</tr>	



						
				<td align ="center" colspan='4'class="bodyblueHead"><b>Control M Specification</b></td></tr>

				<tr height = 35 bgcolor=#EFEFEF>
					
					<td class = bodyblue><LABEL><FONT size=-1><b>Data Centre</b> </FONT></LABEL></td>
					
					<td><%  Value = (scriptVO != null)?scriptVO.getDataCentre_CM():""; %>

				<%	if ("Data Not Available".equals(Value)) {%>
					<INPUT STYLE="  background-color:#72A4D2;"class="bodyblue" type="text" name="DataCentre_CM"  size=30  		value="<%=Value%>" onfocus= "JavaScript:notAvail('DataCentre_CM')" >
					<% } else { %> <INPUT class="bodyblue" type="text" name="DataCentre_CM"  size=30  value="<%=Value%>">
					<% } %>




				
					
			<a href='javascript:openSelectWindow(document.mainPage.DataCentre_CM)'><img src='images/find.gif' border='0'></img></a>
				</td>
			
					<td  class = bodyblue><LABEL><FONT size=-1><b>Application</b> <font color = "red">*</font></FONT></LABEL></td>
					<%  Value = (scriptVO != null)?scriptVO.getApplication_CM():""; %>
					<td><INPUT type="text" name="Application_CM"  size=30 class=bodyblue value="<%=Value%>">
					<a href='javascript:openSelectWindow(document.mainPage.Application_CM)'><img src='images/find.gif' border='0'></img></a>
					</td>
				</tr>	


			<tr height = 35 bgcolor=#EFEFEF>
					
					<td  class = bodyblue><LABEL><FONT size=-1><b>Group</b> </FONT></LABEL></td>
					
						<%  Value = (scriptVO != null)?scriptVO.getGroup_CM():""; %>
					<td>
					<%	if ("Data Not Available".equals(Value)) {%>
					<INPUT STYLE="  background-color:#72A4D2;"class="bodyblue" type="text" name="Group_CM"  size=30  		value="<%=Value%>" onfocus= "JavaScript:notAvail('Group_CM')" >
					<% } else { %> <INPUT class="bodyblue" type="text" name="Group_CM"  size=30  value="<%=Value%>">
					<% } %>
					

					
					<a href='javascript:openSelectWindow(document.mainPage.Group_CM)'><img src='images/find.gif' border='0'></img></a>	
					</td>
				
					
					<td  class = bodyblue><LABEL><FONT size=-1><b>Mem Name</b> </FONT></LABEL></td>
					<td >
						<%  Value = (scriptVO != null)?scriptVO.getMemName_CM():""; %>

						<%	if ("Data Not Available".equals(Value)) {%>
					<INPUT STYLE="  background-color:#72A4D2;"class="bodyblue" type="text" name="MemName_CM"  size=30  		value="<%=Value%>" onfocus= "JavaScript:notAvail('MemName_CM')">
					<% } else { %> <INPUT class="bodyblue" type="text" name="MemName_CM"  size=30  value="<%=Value%>">
					<% } %>
						
					</td>
				</tr>	


				<tr height = 35 bgcolor=#EFEFEF>
					
					<td class = bodyblue><LABEL><FONT size=-1><b>Node ID</b> </FONT></LABEL></td>
					<%  Value = (scriptVO != null)?scriptVO.getNodeID_CM():""; %>
					<td>
					<%	if ("Data Not Available".equals(Value)) {%>
					<INPUT STYLE="  background-color:#72A4D2;"class="bodyblue" type="text" name="NodeID_CM"  size=30  		value="<%=Value%>" onfocus= "JavaScript:notAvail('NodeID_CM')" >
					<% } else { %> <INPUT class="bodyblue" type="text" name="NodeID_CM"  size=30  value="<%=Value%>">
					<% } %>
					

					
					<a href='javascript:openSelectWindow(document.mainPage.NodeID_CM)'><img src='images/find.gif' border='0'></img></a>	
					</td>





					
				
					<td  class = bodyblue><LABEL><FONT size=-1><b>Owner</b> <font color = "red">*</font></FONT></LABEL></td>
					<%  Value = (scriptVO != null)?scriptVO.getOwner_CM():""; %>
					<td><INPUT type="text" name="Owner_CM"  size=30 class=bodyblue value="<%=Value%>">
					<a href='javascript:openSelectWindow(document.mainPage.Owner_CM)'><img src='images/find.gif' border='0'></img></a>
					</td>
				</tr>	
			<tr height = 35 bgcolor=#EFEFEF>
					
					<td  class = bodyblue title="Arguments to be passed"><LABEL><FONT size=-1><b>Command Line</b> </FONT></LABEL></td>
					<td >
						<%  Value = (scriptVO != null)?scriptVO.getCommandLine_CM():""; 

						if ("Data Not Available".equals(Value)) {%>
					<INPUT STYLE="  background-color:#72A4D2;"class="bodyblue" type="text" name="CommandLine_CM"  size=30  		value="<%=Value%>" onfocus= "JavaScript:notAvail('CommandLine_CM')" >
					<% } else { %> <INPUT class="bodyblue" type="text" name="CommandLine_CM"  size=30  value="<%=Value%>">
					<% } %>


					</td>
				
					<td  class = bodyblue><LABEL><FONT size=-1><b>Days </b></FONT></LABEL></td>
					<td >
						<%  Value = (scriptVO != null)?scriptVO.getDays_CM():""; 

						//StringTokenizer st = new StringTokenizer(Value,",");
							%>


						<select class=bodyblue name="Days_CM" id="dayoption" multiple="true" >
						<% /*while (st.hasMoreTokens()) { SValue = st.nextToken(); System.out.println("Svalue"+ SValue); */ %>

	
								
						<option value="Mon" <%=(editflag!=null && Value.indexOf("Mon")!=-1)?"selected":""%> >Mon</option>
						<option value="Tue" <%=(editflag!=null && Value.indexOf("Tue")!=-1)?"selected":""%>>Tue </option>
						<option value="Wed" <%=(editflag!=null && Value.indexOf("Wed")!=-1)?"selected":""%>>Wed </option>
						<option value="Thu" <%=(editflag!=null && Value.indexOf("Thu")!=-1)?"selected":""%>>Thu </option>
						<option value="Fri" <%=(editflag!=null && Value.indexOf("Fri")!=-1)?"selected":""%>>Fri </option>
						<option value="Sat" <%=(editflag!=null && Value.indexOf("Sat")!=-1)?"selected":""%>>Sat </option>
						<option value="Sun" <%=(editflag!=null && Value.indexOf("Sun")!=-1)?"selected":""%>>Sun </option>
						
						<% //} %>
						</select>
						
					</td>
				</tr>	



				<tr height = 35 bgcolor=#EFEFEF >
					
					<td  class = bodyblue><LABEL><FONT size=-1><b>Dependencies IN </b></FONT></LABEL></td>
					<td >
						<%  Value = (scriptVO != null)?scriptVO.getDependenciesIN_CM():""; %>
						
				<select class=bodyblue name="DependenciesIN_CM"  >
						
								
						<option value="None" <%=(editflag!=null && "None".equals(Value))?"selected":""%>>None </option>
						<option value="Yes" <%=(editflag!=null && "Yes".equals(Value))?"selected":""%>>Yes </option>
						<option value="No" <%=(editflag!=null && "No".equals(Value))?"selected":""%>>No </option>
						
						<option value="Several" <%=(editflag!=null && "Several".equals(Value))?"selected":""%>>Several </option>
						
						</select>
					</td>
				
					<td  class = bodyblue><LABEL><FONT size=-1><b>Dependencies OUT</b> </FONT></LABEL></td>
					<td >
						<%  Value = (scriptVO != null)?scriptVO.getDependenciesOUT_CM():""; %>
						<select class=bodyblue name="DependenciesOUT_CM"  >
						
						<option value="None" <%=(editflag!=null && "None".equals(Value))?"selected":""%>>None </option>		
						<option value="Yes" <%=(editflag!=null && "Yes".equals(Value))?"selected":""%>>Yes </option>
						<option value="No" <%=(editflag!=null && "No".equals(Value))?"selected":""%>>No </option>
						
						<option value="Several" <%=(editflag!=null && "Several".equals(Value))?"selected":""%>>Several </option>
						
						</select>

						
					</td>
				</tr>	


				<tr height = 35 bgcolor=#EFEFEF >
					
					<td  class = bodyblue><LABEL><FONT size=-1><b>DependencyIN Names </b></FONT></LABEL><font color = "red">**</font></td>
					<td >
						<%  ///Value = (scriptVO != null)?scriptVO.getDependenciesIN_CM():""; 
					
					DBUtil dbutileditget = new DBUtil(getServletContext());
					
						scriptvoeditget=dbutileditget.getScriptDetailsDep(jobN,serverN);
						Value = (scriptvoeditget != null && scriptvoeditget.getDepInNames_CM() != null)?scriptvoeditget.getDepInNames_CM():"";

					%>
						<%if ("Data Not Available".equals(Value)) {%>
					<INPUT STYLE="  background-color:#72A4D2;"class="bodyblue" type="text" name="DepInNames_CM"  size=30  		value="<%=Value%>" onfocus= "JavaScript:notAvail('DepInNames_CM')" >
					<% } else { %> <INPUT class="bodyblue" type="text" name="DepInNames_CM"  size=30  value="<%=Value%>">
					<% } %>

					
				
					<td  class = bodyblue><LABEL><FONT size=-1><b>DependencyOUT Names</b> </FONT></LABEL></td>
					<td >
						<% 
						Value = (scriptvoeditget != null && scriptvoeditget.getDepOutNames_CM() != null)?scriptvoeditget.getDepOutNames_CM():"";%>


						<%if ("Data Not Available".equals(Value)) {%>
					<INPUT STYLE="  background-color:#72A4D2;"class="bodyblue" type="text" name="DepOutNames_CM"  size=30  		value="<%=Value%>" onfocus= "JavaScript:notAvail('DepOutNames_CM')" >
					<% } else { %> <INPUT class="bodyblue" type="text" name="DepOutNames_CM"  size=30  value="<%=Value%>">
					<% } %>

						
					</td>
				</tr>	


					<tr height = 35 bgcolor=#EFEFEF>
					
					<td  class = bodyblue><LABEL><FONT size=-1><b>Run Time </b></FONT></LABEL><font color = "red">**</font></td>
					<td >
						<%  Value = (scriptVO != null)?scriptVO.getRunTime_CM():"";
				System.out.println("Run time :"+Value);
					if ("Data Not Available".equals(Value)) {%>
						<INPUT STYLE="  background-color:#72A4D2;"class="bodyblue" type="text" name="RunTime_CM"  size=30  		value="<%=Value%>"  onfocus= "JavaScript:notAvail('RunTime_CM')">
					<% } else { %> <INPUT class="bodyblue" type="text" name="RunTime_CM"  size=30  value="<%=Value%>">
					<% } %>
						
					</td>
				
					<td  title="Other Details" class = bodyblue><LABEL><FONT size=-1><b>Miscellaneous</b> </FONT></LABEL></th>
					<td >
						<%  Value = (scriptVO != null)?scriptVO.getMisc_CM():""; 
					if ("Data Not Available".equals(Value)) {%>
						<INPUT STYLE="  background-color:#72A4D2;"class="bodyblue" type="text" name="Misc_CM"  size=30  		value="<%=Value%>"  onfocus= "JavaScript:notAvail('Misc_CM')">
					<% } else { %> <INPUT class="bodyblue" type="text" name="Misc_CM"  size=30  value="<%=Value%>">
					<% } %>
						
					</td>
				</tr>	



				<tr height = 35 bgcolor=#EFEFEF >
					
					<td  title="Status of the Request" class = bodyblue><LABEL><FONT size=-1><b>Status</b></FONT></LABEL></td>
					<td >
						<%  ///Value = (scriptVO != null)?scriptVO.getDependenciesIN_CM():""; 
					
					
						Value = (scriptvoeditget != null && scriptvoeditget.getStatus() != null)?scriptvoeditget.getStatus():"";

					%>
						<select class=bodyblue name="Status"  >
						
						<option value="Open" <%=(editflag!=null && "Open".equals(Value))?"selected":""%>>Open </option>		
						<option value="Closed" <%=(editflag!=null && "Closed".equals(Value))?"selected":""%>>Closed </option>

						</select>
						</td>
				
					<td  title="Your Name" class = bodyblue><LABEL><FONT size=-1><b>User Name</b> </FONT></LABEL><font color = "red">*</font></td>
					<td >
						<% 
						Value = (scriptvoeditget != null && scriptvoeditget.getUsername() != null)?scriptvoeditget.getUsername():"";%>


						<%if ("Data Not Available".equals(Value)) {%>
					<INPUT STYLE="  background-color:#72A4D2;"class="bodyblue" type="text" name="Username"  size=30  		value="<%=Value%>"  >
					<% } else { %> <INPUT class="bodyblue" type="text" name="Username"  size=30  value="<%=Value%>">
					<% } %>

						
					</td>
				</tr>	


			</TABLE>

			

			




			
		
			<TABLE  width="750">
			<% if(editflag == null){ %>

			<tr >
				<td align="left" class='bodyblue'><font color="red">*</font> Required Fields</td>
				<td align="left" class='bodyblue'><font color="red">**</font>Should select either Runtime or DependencyIN Names</td>
				<td align="right" ><INPUT type="button" value="Add" onclick="javascript:aScript('rfrom')" 		     	   class='whitebutton'>
				<INPUT type="button" value="Add&Send" onclick="javascript:addsendScript()"   class='whitebutton'>
				<INPUT type="button" value="Cancel" onclick="javascript:cancelScript()" 		     	   class='whitebutton'></td>
			</tr>


			<% } else { %>
			
		
			<tr >
				<td align="left" class='bodyblue'><font color="red">*</font> Required Fields</td>
				<td align="left" class='bodyblue'><font color="red">**</font>Should select either Runtime or DependencyIN Names</td>
				<td align="right" ><INPUT type="button" value="Save" onclick="javascript:eScript('<%=Jobedit%>','<%=serverN%>')"   class='whitebutton'>
				<INPUT type="button" value="Save&Send" onclick="javascript:sendScript('<%=Jobedit%>','<%=serverN%>')" class='whitebutton'>
				<INPUT type="button" value="Cancel" onclick="javascript:cancelScript()" 		     	   class='whitebutton'>

				


			</td>
			</tr>
			<% } %>
			</TABLE>

<% }  %>





<%	
		
		edited = (String)request.getParameter("edited");
		System.out.println("Edited......*  "+edited);
		System.out.println("added......*  "+added);
	if("yes".equals(edited) && edited != null)



	{
					ScriptVO scriptvoEdit = new ScriptVO();
					DBUtil dbutilEdit = new DBUtil(getServletContext());


					//(String)request.getParameter("FromSource").trim()
					//DBUtil dbutil = new DBUtil();
					scriptvoEdit.setJob((String)request.getParameter("Job"));
					System.out.println("Job..+" + (String)request.getParameter("Job"));
					scriptvoEdit.setRunsFrom((String)request.getParameter("RunsFrom"));
					scriptvoEdit.setFeedDirection((String)request.getParameter("FeedDirection"));
					scriptvoEdit.setFromSource((String)request.getParameter("FromSource"));
					System.out.println("From Source" +(String)request.getParameter("FromSource"));
					scriptvoEdit.setRunsTo((String)request.getParameter("RunsTo"));
					scriptvoEdit.setSummary((String)request.getParameter("Summary"));
					scriptvoEdit.setInternalFilename((String)request.getParameter("InternalFilename"));
					scriptvoEdit.setExternalFilename((String)request.getParameter("ExternalFilename"));
					scriptvoEdit.setLocalContact((String)request.getParameter("LocalContact"));
					scriptvoEdit.setRemoteContact((String)request.getParameter("RemoteContact"));
					scriptvoEdit.setDestBizArea((String)request.getParameter("DestBizArea"));
					scriptvoEdit.setDestBizContact((String)request.getParameter("DestBizContact"));
					scriptvoEdit.setExecutedBy((String)request.getParameter("ExecutedBy"));
					scriptvoEdit.setExecsAnotherScript((String)request.getParameter("ExecsAnotherScript"));
					scriptvoEdit.setDataCentre_CM((String)request.getParameter("DataCentre_CM"));
					scriptvoEdit.setApplication_CM((String)request.getParameter("Application_CM"));
					scriptvoEdit.setGroup_CM((String)request.getParameter("Group_CM"));
					scriptvoEdit.setMemName_CM((String)request.getParameter("MemName_CM"));
					scriptvoEdit.setNodeID_CM((String)request.getParameter("NodeID_CM"));
					scriptvoEdit.setOwner_CM((String)request.getParameter("Owner_CM"));
					scriptvoEdit.setCommandLine_CM((String)request.getParameter("CommandLine_CM"));
					scriptvoEdit.setDependenciesIN_CM((String)request.getParameter("DependenciesIN_CM"));
					scriptvoEdit.setDependenciesOUT_CM((String)request.getParameter("DependenciesOUT_CM"));
					scriptvoEdit.setRunTime_CM((String)request.getParameter("RunTime_CM"));
					scriptvoEdit.setMisc_CM((String)request.getParameter("Misc_CM"));
					scriptvoEdit.setDays_CM((String)request.getParameter("days"));
					System.out.println("Days" + (String)request.getParameter("days"));
					scriptvoEdit.setDepInNames_CM((String)request.getParameter("DepInNames_CM"));
					scriptvoEdit.setDepOutNames_CM((String)request.getParameter("DepOutNames_CM"));
					scriptvoEdit.setStatus((String)request.getParameter("Status"));
					scriptvoEdit.setUsername((String)request.getParameter("Username"));
					dbutilEdit.editScript(scriptvoEdit);
	
					


					
					DBUtil dbutildepedit = new DBUtil(getServletContext());
					dbutildepedit.editScriptDep(scriptvoEdit);

	%>

	<table width="750">		

	<tr><td class='smalltext'><font color='red'>Edited Successfully </font></td>
	<td align="right"> <INPUT type="button" value="Back to List" onclick="javascript:backtomain()" class='whitebutton'> </td></tr>
		
		</table>		
	

	<% } %>


	<TABLE>
	<% 
		added = (String)request.getParameter("added");
		System.out.println("Edited......**********  "+edited);
		System.out.println("added......************  "+added);
		if("yes".equals(added) && added != null)
			{
				System.out.println("added......inside  ************  "+added);
				int flag =0;
				String status = "";
				ScriptVO scriptvoadd = new ScriptVO();
				ArrayList arraylistadd= new ArrayList();
				DBUtil dbutiladd = new DBUtil(getServletContext());
				scriptvoadd.setJob((String)request.getParameter("Job"));
					scriptvoadd.setRunsFrom((String)request.getParameter("RunsFrom"));
					scriptvoadd.setFeedDirection((String)request.getParameter("FeedDirection"));
					scriptvoadd.setFromSource((String)request.getParameter("FromSource"));
					//System.out.println("From Source" +(String)request.getParameter("FromSource"));
					scriptvoadd.setRunsTo((String)request.getParameter("RunsTo"));
					scriptvoadd.setSummary((String)request.getParameter("Summary"));
					scriptvoadd.setInternalFilename((String)request.getParameter("InternalFilename"));
					scriptvoadd.setExternalFilename((String)request.getParameter("ExternalFilename"));
					scriptvoadd.setLocalContact((String)request.getParameter("LocalContact"));
					scriptvoadd.setRemoteContact((String)request.getParameter("RemoteContact"));
					scriptvoadd.setDestBizArea((String)request.getParameter("DestBizArea"));
					scriptvoadd.setDestBizContact((String)request.getParameter("DestBizContact"));
					scriptvoadd.setExecutedBy((String)request.getParameter("ExecutedBy"));
					scriptvoadd.setExecsAnotherScript((String)request.getParameter("ExecsAnotherScript"));
					scriptvoadd.setDataCentre_CM((String)request.getParameter("DataCentre_CM"));
					scriptvoadd.setApplication_CM((String)request.getParameter("Application_CM"));
					scriptvoadd.setGroup_CM((String)request.getParameter("Group_CM"));
					scriptvoadd.setMemName_CM((String)request.getParameter("MemName_CM"));
					scriptvoadd.setNodeID_CM((String)request.getParameter("NodeID_CM"));
					scriptvoadd.setOwner_CM((String)request.getParameter("Owner_CM"));
					scriptvoadd.setCommandLine_CM((String)request.getParameter("CommandLine_CM"));
					scriptvoadd.setDependenciesIN_CM((String)request.getParameter("DependenciesIN_CM"));
					scriptvoadd.setDependenciesOUT_CM((String)request.getParameter("DependenciesOUT_CM"));
					//scriptvoadd.setDependenciesIN_CM((String)request.getParameter("DependenciesIN_CM"));
					scriptvoadd.setDepInNames_CM((String)request.getParameter("DepInNames_CM"));
					scriptvoadd.setDepOutNames_CM((String)request.getParameter("DepOutNames_CM"));
					scriptvoadd.setMisc_CM((String)request.getParameter("Misc_CM"));
					scriptvoadd.setRunTime_CM((String)request.getParameter("RunTime_CM"));
					System.out.println(" Runtime" + (String)request.getParameter("RunTime_CM"));

					scriptvoadd.setDays_CM((String)request.getParameter("days"));
					scriptvoadd.setStatus((String)request.getParameter("Status"));
					scriptvoadd.setUsername((String)request.getParameter("Username"));
					
				
				
				//String act = (String)request.getParameter("Action");
				//System.out.println("ACT" + act);
				//if("yes".equals(act)){ 
					/*if( scriptvoadd.getJob().equals("")){
						out.println("<tr><td class='smalltext'><font color='red'>Job field cannot be " +"blank</font></td></tr>");
					}
					if( scriptvoadd.getServerName().equals("")){
						out.println("<tr><td class='smalltext'><font color='red'>ServerName field cannot be " +"blank</font></td></tr>");
					}
					else{*/

					arraylistadd.add(scriptvoadd);
					status=dbutiladd.addScriptDB(arraylistadd);

				if("Script added successfully".equals(status)){
					DBUtil dbutildep = new DBUtil(getServletContext());
					dbutildep.addScriptDBDep(scriptvoadd);
				}
				else{
					savesend ="no";
				}



					
				
			 %>
			

			<table width="750">		
			<tr><td class='smalltext'><font color='red'><%= status %></font></td>
			<td  align="right"><INPUT type="button" value="Add New Script" onclick="javascript:addN()" class='whitebutton'>
			<INPUT type="button" value="Back to List" onclick="javascript:backtomain()" class='whitebutton'> </td></tr>
		
			</table>	


		<% } %>
		
<%		if("yes".equals(savesend)){
		//String sender = getServletContext().getInitParameter("mail.sender");
		//String mailserver = getServletContext().getInitParameter("mail.server");
		//String header = getServletContext().getInitParameter("mail.header");
		String sender ="";
		String mailserver="";
		String header ="";
		 try {
            //File propfile = new File(System.getProperty("tracker.properties.home")+"/"+"STtracker.properties");
			Properties property = new Properties();
            File propfile = new File(getServletContext().getInitParameter("tracker.properties.home")+"/"+"STtracker.properties");
			InputStream in = new FileInputStream(propfile);
            property.load(in);
            sender = property.getProperty("Sender");
			System.out.println("sender " +  sender);
			mailserver = property.getProperty("MailServer");
			header= property.getProperty("Header");
            //System.out.println("11111111111111111111111");
      
		MailClass mailclass= new MailClass(mailserver);
		StringBuffer content = new StringBuffer();
		//String sender;
		
		DBUtil dbutil = new DBUtil(getServletContext());
		ArrayList maillist = new ArrayList();
		maillist=dbutil.getMailList();
		String Dayscript =(String)request.getParameter("days");
		if(!"".equals(Dayscript)){

		Dayscript=Dayscript.substring(1); 
		}
		int size = maillist.size(); 	
		String receive[] = new String[size];
		System.out.println("size" + size);
		for(int i=0;i<size;i++)
		{
			MailListVO maillistvo = (MailListVO) maillist.get(i);
			receive[i]=maillistvo.getEmail();
			System.out.println("rec " + receive[i]);
		}
			

		content.append("Please arrange to add/update following ControlM job  \t\t\t\t\t\t\t");
		content.append(new Date());
		content.append("\n\tJob Name : ");
		content.append((String)request.getParameter("Job"));
		content.append(" \n\tGroup : ");
		content.append((String)request.getParameter("Group_CM"));
		content.append( "\n\tApplication : " );
		content.append((String)request.getParameter("Application_CM"));
		content.append("\n\tNode ID : " );
		content.append((String)request.getParameter("NodeID_CM")); 
		content.append("\n\tOwner : " );
		content.append((String)request.getParameter("Owner_CM"));
		content.append("\n\tTime From : ");
		content.append((String)request.getParameter("RunTime_CM"));
		content.append("\n\tJob Description :");
		content.append((String)request.getParameter("Summary") );
		content.append("\n\tDays : ");
		content.append( Dayscript );
		content.append("\n\tCommand Line : ");
		content.append( (String)request.getParameter("CommandLine_CM"));  
		content.append("\n\tDependencies : ");
		content.append((String)request.getParameter("DepInNames_CM"));  
		content.append("\n\nThanks&Regards,\n" );
		content.append((String)request.getParameter("Username"));
		content.append(".");
		String to[] = new String[2];
		
		mailclass.postMail(receive,header,content.toString(),sender);
		  }
        catch(Exception e) {
            System.out.println("LOADFILE>>>>>CONSTRUCTOR" + e);
        }


%> <table width="750">		

	<td class='smalltext'><font color='red'>Mail Sent Successfully </font></td>
	</table>


<%}

%>






		
	<%		}
			}
		catch(Exception e) {
				e.printStackTrace();
		}

		
		
		%>

</TABLE>




</FORM>
</BODY>
</HTML> 

